﻿using System.Collections.ObjectModel;
using System.ComponentModel;
using LibQuestionIsPhone.Models;

namespace InterviewAppPhone.ViewModels
{
    public class DifficoltaViewModel : INotifyPropertyChanged
    {
        public ObservableCollection<Difficolta> Items { get; private set; }

        private bool _isConnection;

        public bool IsConnection
        {
            get { return _isConnection; }
            set
            {
                _isConnection = value;
                OnPropertyChanged("IsConnection");
                OnPropertyChanged("IsAssenzaRete");
            }
        }

        public bool IsAssenzaRete
        {
            get { return !IsConnection; }
        }

        private bool _isCalculate { get; set; }
        public bool IsCalculate
        {
            get { return _isCalculate; }
            set
            {
                _isCalculate = value;
                OnPropertyChanged("IsCalculate");
            }
        }
        private bool _isDataLoaded { get; set; }

        public bool IsDataLoaded
        {
            get { return _isDataLoaded; }
            private set
            {
                _isDataLoaded = value;
                OnPropertyChanged("IsDataLoaded");
            }
        }



        /// <summary>
        /// Crea e aggiunge alcuni oggetti ItemViewModel nella raccolta di elementi.
        /// </summary>
        public void LoadData()
        {
            Items = new ObservableCollection<Difficolta>();
            foreach (var item in DataFlowObject.ListDifficolta)
            {
                this.Items.Add(item);
            }
            IsDataLoaded = true;
        }
        public event PropertyChangedEventHandler PropertyChanged;
        protected void OnPropertyChanged(string name)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(name));
            }
        }
    }
}
